﻿using System.Collections.Generic;
using UnityEngine;

namespace HotPlayer.Physic2D
{
    public class Simplex
    {
        private List<Vector2> points = new List<Vector2>(3);

        public int Count => points.Count;

        public Vector2 this[int index]
        {
            get
            {
                return points[index];
            }
            set
            {
                points[index] = value;
            }
        }

        public void Clear()
        {
            points.Clear();
        }

        public void Add(Vector2 point)
        {
            points.Add(point);
        }

        public void RemoveAt(int index)
        {
            points.RemoveAt(index);
        }

        public bool ContainsOrigin()
        {
            return MathUtils.Contains(points[0], points[1], points[2], Vector2.zero);
        }

        public void Insert(int index, Vector2 point)
        {
            points.Insert(index, point);
        }
    }
}